package com.api.shopapi.mapper;

import com.api.shopapi.entity.ReportImg;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface ReportImgMapper {

    @Insert("insert into report_img (ReportImgCode,ReportCode,Url,Sort) values " +
            "(#{reportImg.ReportImgCode},#{reportImg.ReportCode},#{reportImg.Url},#{reportImg.Sort})")
    int insert(@Param("reportImg") ReportImg reportImg);

    @Update("update report_img set ReportCode=#{reportImg.ReportCode},Url=#{reportImg.Url},Sort=#{reportImg.Sort} " +
            "where ReportImgCode=#{reportImg.ReportImgCode}")
    int update(@Param("reportImg") ReportImg reportImg);

    @Delete("delete from report_img where ReportImgCode=#{reportImgCode}")
    int delete(@Param("reportImgCode") String reportImgCode);

    @Select("select * from report_img where ReportImgCode=#{reportImgCode} limit 1")
    ReportImg getByReportImgCode(@Param("reportImgCode") String reportImgCode);

    @Select("select * from report_img where ReportCode=#{reportCode} order by Sort desc")
    List<ReportImg> getListByReportCode(@Param("reportCode") String reportCode);

}
